<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.9.0">
    

    

    



    <meta charset="utf-8">
    
    
    
    
    <title>Spring 依赖注入 | 欢迎参观小灰灰的网站哟 ヾ(◍°∇°◍)ﾉﾞ ~ | It&#39;s founded on March 9, 2019 and the open source address for the blog notes https://github.com/YUbuntu0109/YUbuntu0109.github.io</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#3F51B5">
    
    
    <meta name="keywords" content="Spring">
    <meta name="description" content="Spring framework 依赖注入篇如果想区分依赖注入与控制反转(IOC)两者之间的不同,可以参考Martin Fowler给出的解释.查看文章: GO  简单来说,依赖注入的情况如下 : 12345678public class A &amp;#123;    public void importantMethod() &amp;#123;        B b = ... // get an inst">
<meta name="keywords" content="Spring">
<meta property="og:type" content="article">
<meta property="og:title" content="Spring 依赖注入">
<meta property="og:url" content="http://yoursite.com/2019/04/02/Spring-依赖注入/index.html">
<meta property="og:site_name" content="欢迎参观小灰灰的网站哟 ヾ(◍°∇°◍)ﾉﾞ ~">
<meta property="og:description" content="Spring framework 依赖注入篇如果想区分依赖注入与控制反转(IOC)两者之间的不同,可以参考Martin Fowler给出的解释.查看文章: GO  简单来说,依赖注入的情况如下 : 12345678public class A &amp;#123;    public void importantMethod() &amp;#123;        B b = ... // get an inst">
<meta property="og:locale" content="en">
<meta property="og:updated_time" content="2019-10-31T05:19:50.657Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Spring 依赖注入">
<meta name="twitter:description" content="Spring framework 依赖注入篇如果想区分依赖注入与控制反转(IOC)两者之间的不同,可以参考Martin Fowler给出的解释.查看文章: GO  简单来说,依赖注入的情况如下 : 12345678public class A &amp;#123;    public void importantMethod() &amp;#123;        B b = ... // get an inst">
    
        <link rel="alternate" type="application/atom+xml" title="欢迎参观小灰灰的网站哟 ヾ(◍°∇°◍)ﾉﾞ ~" href="/atom.xml">
    
    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="stylesheet" href="//unpkg.com/hexo-theme-material-indigo@latest/css/style.css">
    <script>window.lazyScripts=[]</script>

    <!-- custom head -->
    

</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide" >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(/img/brand.jpg)">
      <div class="brand">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="/img/my-portrait.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">黄宇辉</h5>
          <a href="mailto:3083968068@qq.com" title="3083968068@qq.com" class="mail">3083968068@qq.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/"  >
                <i class="icon icon-lg icon-home"></i>
                homepage
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/archives"  >
                <i class="icon icon-lg icon-archives"></i>
                Archives
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags"  >
                <i class="icon icon-lg icon-tags"></i>
                Tags
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/categories"  >
                <i class="icon icon-lg icon-th-list"></i>
                Categories
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/YUbuntu0109" target="_blank" >
                <i class="icon icon-lg icon-github"></i>
                Github
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/YUbuntu0109" target="_blank" >
                <i class="icon icon-lg icon-weibo"></i>
                Weibo
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/custom"  >
                <i class="icon icon-lg icon-link"></i>
                Test
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">Spring 依赖注入</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="Search">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        

        <!-- background music(Mar 11,2019 AM) -->
        <div>
            <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=280 height=52 src="//music.163.com/outchain/player?type=2&id=438801642&auto=1&height=32"></iframe>
        </div>
        <!---------------------->
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">Spring 依赖注入</h1>
        <h5 class="subtitle">
            
                <time datetime="2019-04-02T21:12:43.000Z" itemprop="datePublished" class="page-time">
  2019-04-02
</time>


            
        </h5>
    </div>

    


</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap post-toc-shrink" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#Spring-framework-依赖注入篇"><span class="post-toc-number">1.</span> <span class="post-toc-text">Spring framework 依赖注入篇</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#下面为从类路径中加载applicationContext1-xml和applicationContext2-xml的ApplicationContext创建的一个代码示例"><span class="post-toc-number">1.0.1.</span> <span class="post-toc-text">下面为从类路径中加载applicationContext1.xml和applicationContext2.xml的ApplicationContext创建的一个代码示例 :</span></a></li></ol></li></ol></li></ol>
        </nav>
    </aside>


<article id="post-Spring-依赖注入"
  class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">Spring 依赖注入</h1>
        <div class="post-meta">
            <time class="post-time" title="2019-04-02 21:12:43" datetime="2019-04-02T21:12:43.000Z"  itemprop="datePublished">2019-04-02</time>

            


            

        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h2 id="Spring-framework-依赖注入篇"><a href="#Spring-framework-依赖注入篇" class="headerlink" title="Spring framework 依赖注入篇"></a>Spring framework <code>依赖注入篇</code></h2><p><em>如果想区分<code>依赖注入</code>与<code>控制反转(IOC)</code>两者之间的不同,可以参考<code>Martin Fowler</code>给出的解释.查看文章: <a href="http://martinfowler.com/articles/injection.html" target="_blank" rel="noopener">GO</a></em></p>
<ul>
<li><p><em>简单来说,依赖注入的情况如下 :</em></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">A</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">importantMethod</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        B b = ... <span class="comment">// get an instance of B</span></span><br><span class="line">        b.usefulMethod();</span><br><span class="line">        ...</span><br><span class="line">    &#125;</span><br><span class="line">    ...</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p><em>如果要使用<code>B</code>,类<code>A</code>必须先获得组件<code>B</code>的实例引用,若<code>B</code>是一个具体类,则可以通过<code>new</code>关键字直接创建组件<code>B</code>实例.</em>但是,如果<code>B</code>是接口,且有多个实现,则问题就变得复杂了,我们固然可以任意选择接口<code>B</code>的一个实现类,但这也意味着<code>A</code>的可重用性大大降低了,因为无法采用<code>B</code>的其他实现.*</p>
</li>
<li><p><em>依赖注入是这样处理此类情景的 : 接管对象的创建工作,并将该对象的引用注入需要该对象的组件.以上述例子为例,依赖注入</em>框架会分别创建对象<code>A</code>和对象<code>B</code>,将对象<code>B</code>注入到对象<code>A</code>中.为了能让框架进行依赖注入,程序员需要编写特定的<code>set</code>方法<em>或构建方法,例如: 为了能将<code>B</code>注入到<code>A</code>中,类<code>A</code>会被修改成如下形式 :</em></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">A</span> </span>&#123;</span><br><span class="line">    <span class="keyword">private</span> B b;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">importantMethod</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="comment">// no need to worry about creating B anymore.</span></span><br><span class="line">        <span class="comment">// B b = ... // get an instance of B.</span></span><br><span class="line">        b.usefulMethod();</span><br><span class="line">        ...</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setB</span><span class="params">(B b)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.b = b;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p><em>修改后的类<code>A</code>新增了一个<code>setter</code>方法,该方法将会被框架调用,以注入一个<code>B</code>的实例.由于对象依赖由依赖注入,类<code>A</code>的<code>importantMethod()</code>方法不再需要在调用<code>B</code>的<code>usefulMethod()</code>方法前去创建一个<code>B</code>的实例.</em></p>
</li>
<li><p><em>当然,也可以采用<code>构造器方式</code>注入,如下所示 : (本例中,<code>Spring</code>会先创建<code>B</code>的实例,再创建实例<code>A</code>,然后把<code>B</code>注入到实例<code>A</code>中.)</em></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">A</span> </span>&#123;</span><br><span class="line">    <span class="keyword">private</span> B b;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="title">A</span><span class="params">(B b)</span></span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.b = b;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">importantMethod</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="comment">// no need to worry about creating B anymore.</span></span><br><span class="line">        <span class="comment">// B b = ... // get an instance of B.</span></span><br><span class="line">        b.usefulMethod();</span><br><span class="line">        ...</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p><strong>注意 : <code>Spring</code> 管理的对象称为<code>beans</code> .</strong></p>
</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">通过提供一个控制反转器(或者依赖注入器IOC),`Spring`为我们提供一种可以&apos;聪明&apos;地管理Java对象的依赖关系的方法.</span><br><span class="line">其优雅之处在于 : 程序员无须了解`Spring`框架的存在,更不需要引入任何`Spring`类型.</span><br><span class="line"></span><br><span class="line">使用`Spring`,程序几乎将所有重要对象的创建工作移交给了`Spring`,并配置如何注入依赖.`Spring`支持`XML`和`注解`</span><br><span class="line">两种配置方式.此外还需要创建是一个`ApplicationContext`对象,其代表一个`Spring`控制反转容器,`org.springframework.</span><br><span class="line">context.ApplicationContext`接口有多个实现,包括`ClassPathXmlApplicationContext`和`FileSystemXmlApplicationContext`.</span><br><span class="line">这两个实现都需要至少一个包含`beans`信息的`XML`文件.</span><br></pre></td></tr></table></figure>
<ul>
<li><em>ClassPathXmlApplicationContext : 在类加载路径中加载配置文件.</em></li>
<li><em>FileSystemXmlApplicationContext : 在文件系统路径中加载文件.</em></li>
</ul>
<h4 id="下面为从类路径中加载applicationContext1-xml和applicationContext2-xml的ApplicationContext创建的一个代码示例"><a href="#下面为从类路径中加载applicationContext1-xml和applicationContext2-xml的ApplicationContext创建的一个代码示例" class="headerlink" title="下面为从类路径中加载applicationContext1.xml和applicationContext2.xml的ApplicationContext创建的一个代码示例 :"></a>下面为从类路径中加载<code>applicationContext1.xml</code>和<code>applicationContext2.xml</code>的<code>ApplicationContext</code>创建的一个代码示例 :</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">ApplicationContext context = <span class="keyword">new</span> ClassPathXmlApplicationContext(</span><br><span class="line">    <span class="keyword">new</span> String[]&#123;<span class="string">"applicationContext1.xml"</span>,<span class="string">"applicationContext2.xml"</span>&#125;)</span><br><span class="line"></span><br><span class="line"><span class="comment">//可以通过调用`ApplicationContext`的`getBean`方法获得对象</span></span><br><span class="line"><span class="comment">//getBean方法会查询`id`为`product`且类型为`Product`的`bean`对象.</span></span><br><span class="line">Product product = context.getBean(<span class="string">"product"</span>,Product.class);</span><br></pre></td></tr></table></figure>
<ul>
<li><p><strong>注 : 理想情况下,我们仅需在测试代码中创建一个<code>ApplicationContext</code>,应用程序本身无需处理,对于<code>Spring MVC</code>应用,可以通过一个<code>Spring Servlet</code>来处理<code>ApplicationContext</code>,既而无须直接处理.</strong></p>
</li>
<li><p><em>摘抄书籍 : 《 Servlet,JSP and Spring MVC - beginner 》 -&gt;  author: [加] Budi Kurniawan [美] Paul Deck</em></p>
</li>
</ul>

        </div>

        <blockquote class="post-copyright">
    
    <div class="content">
        
<span class="post-time">
    Last updated: <time datetime="2019-10-31T05:19:50.657Z" itemprop="dateUpdated">2019-10-31 05:19:50</time>
</span><br>


        
    </div>
    
    <footer>
        <a href="http://yoursite.com">
            <img src="/img/my-portrait.jpg" alt="黄宇辉">
            黄宇辉
        </a>
    </footer>
</blockquote>

        
<div class="page-reward">
    <a id="rewardBtn" href="javascript:;" class="page-reward-btn waves-effect waves-circle waves-light">赏</a>
</div>



        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Spring/">Spring</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://yoursite.com/2019/04/02/Spring-依赖注入/&title=《Spring 依赖注入》 — 欢迎参观小灰灰的网站哟 ヾ(◍°∇°◍)ﾉﾞ ~&pic=http://yoursite.com/img/my-portrait.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://yoursite.com/2019/04/02/Spring-依赖注入/&title=《Spring 依赖注入》 — 欢迎参观小灰灰的网站哟 ヾ(◍°∇°◍)ﾉﾞ ~&source=My Personal Website For Blog" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://yoursite.com/2019/04/02/Spring-依赖注入/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《Spring 依赖注入》 — 欢迎参观小灰灰的网站哟 ヾ(◍°∇°◍)ﾉﾞ ~&url=http://yoursite.com/2019/04/02/Spring-依赖注入/&via=http://yoursite.com" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://yoursite.com/2019/04/02/Spring-依赖注入/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/2019/04/03/Simple-Factory-Pattern/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">Simple Factory Pattern</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/2019/03/31/全国计算机等级考试-三级数据库技术/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">全国计算机等级考试-三级数据库技术</h4>
      </a>
    </div>
  
</nav>



    




















</article>

<div id="reward" class="page-modal reward-lay">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <h3 class="reward-title">
        <i class="icon icon-quote-left"></i>
        thanks ~
        <i class="icon icon-quote-right"></i>
    </h3>
    <div class="reward-content">
        
        <div class="reward-code">
            <img id="rewardCode" src="/img/Wechat_appreciates.png" alt="打赏二维码">
        </div>
        
    </div>
</div>



</div>

        <footer class="footer">
    <div class="top">
        

        <p>
            
                <span><a href="/atom.xml" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            
            <span>This blog is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.</span>
        </p>
    </div>
    <div class="bottom">
        <!-- 统计网站用户访问量. 技术支持：不蒜子(http://busuanzi.ibruce.info/) ————> Mar 13,2019 -->
        <p>
            <font style='font-size: 12px;color:springgreen'>
                    <div align="center">
                        <!-- 安装脚本 -->
                        <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
                        <!-- 安装标签 -->
                        <span id="busuanzi_container_site_pv">
                            ◎用户总访问量 : <span id="busuanzi_value_site_pv"></span> 次 ~ &nbsp&nbsp
                        </span>
                        <span id="busuanzi_container_site_uv">
                            ◎总访客数(（づ￣3￣）づ╭❤～) : <span id="busuanzi_value_site_uv"></span>人 ~
                        </span>
                    </div>
                </font>
            </p>
            <!---------->
            <p>
                <font style='font-size: 10px'>
                    <span>黄宇辉 &copy; 2019</span>
                    <span>
                        
                        Blog source <a href="https://github.com/YUbuntu0109/YUbuntu0109.github.io" target="_blank">Github</a> 
                        Power by <a href="http://hexo.io/" target="_blank">Hexo</a>
                        Theme <a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a>
                    </span>
                </font>
            </p>
        </div>
    </footer>
    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://yoursite.com/2019/04/02/Spring-依赖注入/&title=《Spring 依赖注入》 — 欢迎参观小灰灰的网站哟 ヾ(◍°∇°◍)ﾉﾞ ~&pic=http://yoursite.com/img/my-portrait.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://yoursite.com/2019/04/02/Spring-依赖注入/&title=《Spring 依赖注入》 — 欢迎参观小灰灰的网站哟 ヾ(◍°∇°◍)ﾉﾞ ~&source=My Personal Website For Blog" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://yoursite.com/2019/04/02/Spring-依赖注入/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《Spring 依赖注入》 — 欢迎参观小灰灰的网站哟 ヾ(◍°∇°◍)ﾉﾞ ~&url=http://yoursite.com/2019/04/02/Spring-依赖注入/&via=http://yoursite.com" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://yoursite.com/2019/04/02/Spring-依赖注入/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="//api.qrserver.com/v1/create-qr-code/?data=http://yoursite.com/2019/04/02/Spring-依赖注入/" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: true };


</script>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/main.min.js"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/search.min.js" async></script>








<script>
(function() {
    var OriginTitile = document.title, titleTime;
    document.addEventListener('visibilitychange', function() {
        if (document.hidden) {
            document.title = 'Where are you going ?';
            clearTimeout(titleTime);
        } else {
            document.title = 'As long as you love me ~';
            titleTime = setTimeout(function() {
                document.title = OriginTitile;
            },2000);
        }
    });
})();
</script>



</body>
</html>
